import tensorflow as tf

x = tf.linspace(-10., 10., 21)

with tf.GradientTape() as tape:
    tape.watch(x)
    y = tf.nn.relu(x)

gradient = tape.gradient(y, [x])

print('x:\n', x)
print('relu(x): \n', tf.nn.relu(x))
print('gradient: \n{}'.format(gradient))
